﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Xml.Serialization;
using System.IO;
using System.Reflection;
using System.ComponentModel;

namespace QbiconEditor
{
  public class QPreferences
  {

    #region Colors

    private Color activeObjectFrameColor = Color.LightBlue;
    private Color invisibleObjectFrameColor = Color.Maroon;
    private Color activePointFrameColor = Color.DodgerBlue;
    private Color enabledObjectColor = Color.Lime;
    private Color disabledObjectColor = Color.Red;
    private Color gridColor = Color.SkyBlue;
    private Color axisColor = Color.DarkBlue;
    private Color selectionRectColor = Color.Blue;
    private Color hintFrameColor = Color.DodgerBlue;
    private Color hintTextColor = Color.Black;
    private Color hintBackColor = Color.White;

    [CategoryAttribute("Colors")]
    [XmlIgnore()]
    public Color SelectionRectColor
    {
      get
      {
        return selectionRectColor;
      }
      set
      {
        selectionRectColor = value;
      }
    }

    [CategoryAttribute("Colors")]
    [XmlIgnore()]
    public Color ActiveObjectFrameColor
    {
      get
      {
        return activeObjectFrameColor;
      }
      set
      {
        activeObjectFrameColor = value;
      }
    }

    [CategoryAttribute("Colors")]
    [XmlIgnore()]
    public Color ActivePointFrameColor
    {
      get
      {
        return activePointFrameColor;
      }
      set
      {
        activePointFrameColor = value;
      }
    }

    [CategoryAttribute("Colors")]
    [XmlIgnore()]
    public Color HintBackColor
    {
      get
      {
        return hintBackColor;
      }
      set
      {
        hintBackColor = value;
      }
    }

    [CategoryAttribute("Colors")]
    [XmlIgnore()]
    public Color HintFrameColor
    {
      get
      {
        return hintFrameColor;
      }
      set
      {
        hintFrameColor = value;
      }
    }

    [CategoryAttribute("Colors")]
    [XmlIgnore()]
    public Color HintTextColor
    {
      get
      {
        return hintTextColor;
      }
      set
      {
        hintTextColor = value;
      }
    }

    [XmlIgnore()]
    [CategoryAttribute("Colors")]
    public Color InvisibleObjectFrameColor
    {
      get
      {
        return invisibleObjectFrameColor;
      }
      set
      {
        invisibleObjectFrameColor = value;
      }
    }

    [CategoryAttribute("Colors")]
    [XmlIgnore()]
    public Color GridColor
    {
      get
      {
        return gridColor;
      }
      set
      {
        gridColor = value;
      }
    }

    [XmlIgnore()]
    [CategoryAttribute("Colors")]
    public Color AxisColor
    {
      get
      {
        return axisColor;
      }
      set
      {
        axisColor = value;
      }
    }

    [CategoryAttribute("Colors")]
    [XmlIgnore()]
    public Color DisabledObjectColor
    {
      get
      {
        return disabledObjectColor;
      }
      set
      {
        disabledObjectColor = value;
      }
    }

    [Browsable(false)]
    public int SelectionRectColorARGB
    {
      get
      {
        return selectionRectColor.ToArgb();
      }
      set
      {
        selectionRectColor = Color.FromArgb(value);
      }
    }

    [Browsable(false)]
    public int ActiveObjectFrameColorARGB
    {
      get
      {
        return activeObjectFrameColor.ToArgb();
      }
      set
      {
        activeObjectFrameColor = Color.FromArgb(value);
      }
    }

    [Browsable(false)]
    public int ActivePointFrameColorARGB
    {
      get
      {
        return activePointFrameColor.ToArgb();
      }
      set
      {
        activePointFrameColor = Color.FromArgb(value);
      }
    }

    [Browsable(false)]
    public int HintBackColorARGB
    {
      get
      {
        return hintBackColor.ToArgb();
      }
      set
      {
        hintBackColor = Color.FromArgb(value);
      }
    }

    [Browsable(false)]
    public int HintFrameColorARGB
    {
      get
      {
        return hintFrameColor.ToArgb();
      }
      set
      {
        hintFrameColor = Color.FromArgb(value);
      }
    }

    [Browsable(false)]
    public int HintTextColorARGB
    {
      get
      {
        return hintTextColor.ToArgb();
      }
      set
      {
        hintTextColor = Color.FromArgb(value);
      }
    }

    [Browsable(false)]
    public int InvisibleObjectFrameColorARGB
    {
      get
      {
        return invisibleObjectFrameColor.ToArgb();
      }
      set
      {
        invisibleObjectFrameColor = Color.FromArgb(value);
      }
    }

    [Browsable(false)]
    public int GridColorARGB
    {
      get
      {
        return gridColor.ToArgb();
      }
      set
      {
        gridColor = Color.FromArgb(value);
      }
    }

    [Browsable(false)]
    public int AxisColorARGB
    {
      get
      {
        return axisColor.ToArgb();
      }
      set
      {
        axisColor = Color.FromArgb(value);
      }
    }

    [Browsable(false)]  
    public int DisabledObjectColorARGB
    {
      get
      {
        return disabledObjectColor.ToArgb();
      }
      set
      {
        disabledObjectColor = Color.FromArgb(value);
      }
    }

    #endregion

    #region Sizes
    
    private int pointFrameRectWidth = 4;
    private int framePenWidth = 2;
    private int centerCrossSize = 3;
    private int selectionRectPenWidth = 1;

    private float gridCellSize = 1;
    private float hintTextSize = 8;

    [CategoryAttribute("Sizes")]
    public int PointFrameRectWidth
    {
      get
      {
        return pointFrameRectWidth;
      }
      set
      {
        pointFrameRectWidth = value;
      }
    }

    [CategoryAttribute("Sizes")]
    public int FrameRectPenWidth
    {
      get
      {
        return framePenWidth;
      }
      set
      {
        framePenWidth = value;
      }
    }

    [CategoryAttribute("Sizes")]
    public int ObjectCenterCrossSize
    {
      get
      {
        return centerCrossSize;
      }
      set
      {
        centerCrossSize = value;
      }
    }

    [CategoryAttribute("Sizes")]
    public int SelectionRectPenWidth
    {
      get
      {
        return selectionRectPenWidth;
      }
      set
      {
        selectionRectPenWidth = value;
      }
    }

    [CategoryAttribute("Sizes")]
    public float GridCellSize
    {
      get
      {
        return gridCellSize;
      }
      set
      {
        gridCellSize = value;
      }
    }

    [CategoryAttribute("Sizes")]
    public float HintTextSize
    {
      get
      {
        return hintTextSize;
      }
      set
      {
        hintTextSize = value;
      }
    }

    #endregion

    #region Editor preferences

    private bool topOnBottom = true;
    private bool showGrid = true;
    private bool showAxes = true;
    private bool showObjectRect = true;
    private bool useTextures = true;
    private bool showPointsHints = true;

    [CategoryAttribute("Options")]
    public bool ShowGrid
    {
      get
      {
        return showGrid;
      }
      set
      {
        showGrid = value;
      }
    }

    [CategoryAttribute("Options")]
    public bool ShowAxes
    {
      get
      {
        return showAxes;
      }
      set
      {
        showAxes = value;
      }
    }

    [CategoryAttribute("Options")]
    public bool UseTextures
    {
      get
      {
        return useTextures;
      }
      set
      {
        useTextures = value;
      }
    }

    [CategoryAttribute("Options")]
    public bool TopOnBottom
    {
      get
      {
        return topOnBottom;
      }
      set
      {
        topOnBottom = value;
      }
    }

    [CategoryAttribute("Options")]
    public bool ShowObjectRect
    {
      get
      {
        return showObjectRect;
      }
      set
      {
        showObjectRect = value;
      }
    }

    [CategoryAttribute("Options")]
    public bool ShowPointsHints
    {
      get
      {
        return showPointsHints;
      }
      set
      {
        showPointsHints = value;
      }
    }
    
    #endregion 
  }
}
